package luj.groovy.excel.internal.table.header

import groovy.transform.PackageScope
import luj.groovy.excel.api.table.header.HeaderField

import java.util.stream.Collectors

@PackageScope
class FieldImpl implements HeaderField {

  @Override
  String getName() {
    return _name
  }

  @Override
  int getFieldIndex() {
    return _index
  }

  @Override
  List<HeaderField> getChildFields() {
    return _childList
  }

  @Override
  String toString() {
    return _name + '[' + _childList.stream()
        .map { it.toString() }
        .collect(Collectors.joining(',')) + ']'
  }

  String _name
  int _index

  HeaderField _parent
  List<HeaderField> _childList
}
